<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/personal.css"/>
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="js/personal.js"></script>
    <title>个人中心-我的简历</title>
</head>

<body>
<div class="header">
    <div class="headerMain">
        <div class="Notice">
        </div>
        <div class="Account">
            <div class="Left">
                <div class="Info">
                    <font>[28421947]</font>
                    <input type="button">
                    <div id="InfoPopup">
                        <ul>
                            <li><a href="../../../../target/classes/public/index.html">退出</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="navTop">
    <div class="navTopmain">
        <div class="logo"><a href="../../../../target/classes/public/index.html"><img src="images/logo_1.png"/><img src="images/logo_2.png"/></a></div>
    </div>
</div>
<div class="personalBody">
    <div id="base_div" class="perRightcon">
        <div class="JlBoxTit">
            <p class="tit1">基本资料/求职意向</p>
            <div class="tit2"></div>
            <p class="tit3">最高学历</p>
        </div>
        <div class="JlBoxCon">
            <h1><span>基本信息</span>
                <div></div>
            </h1>
            <div class="JlBoxLeft">
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>姓 名：</div>
                    <div class="inputtxt">
                        <input name="name" type="text" class="txt1"/>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>性 别：</div>
                    <div class="inputtxt">
                        <div class="sex on">男</div>
                        <div class="sex">女</div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>出生年月：</div>
                    <div class="inputtxt">
                        <input name="brith" type="date" class="txt8"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>现居住地：</div>
                    <div class="inputtxt">
                        <input name="nowLocation" type="text" class="txt7"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>户口所在地：</div>
                    <div class="inputtxt">
                        <input name="householdLocation" type="text" class="txt7"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>我成长在：</div>
                    <div class="inputtxt">
                        <input name="hometown" type="text" class="txt7"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>手机号码：</div>
                    <div class="inputtxt">
                        <input type="text" name="phone" class="txt7">
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>电子邮箱：</div>
                    <div class="inputtxt">
                        <input name="email" type="text" class="txt3"/>
                        <b>可用来登录</b>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="JlBoxCon">
            <h1><span>求职意向</span>
                <div></div>
            </h1>
            <div class="JlBoxLeft">
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>求职状态：</div>
                    <div class="inputtxt">
                        <select class="txtcon txt2" id="jobStatus">
                            <option value="离职-随时到岗">离职-随时到岗</option>
                            <option value="在职-月内到岗">在职-月内到岗</option>
                            <option value="在职-考虑机会">在职-考虑机会</option>
                            <option value="在职-暂不考虑">在职-暂不考虑</option>
                        </select>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>相关工作经验：</div>
                    <div class="inputtxt">
                        <div class="typeJob1 on">有</div>
                        <div class="typeJob1">无</div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>期望工作性质：</div>
                    <div class="inputtxt">
                        <div class="typeJob2 on">全职</div>
                        <div class="typeJob2">兼职</div>
                        <div class="typeJob2">实习</div>
                        <div class="clear"></div>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>期望月薪：</div>
                    <div class="inputtxt">
                        <select class="txtcon txt2" id="expectSal">
                            <option value="面议">面议</option>
                            <option value="30000以上">30000以上</option>
                            <option value="20000-30000">20000-30000</option>
                            <option value="10000-20000">10000-20000</option>
                            <option value="5000-10000">5000-10000</option>
                            <option value="5000以下">5000以下</option>
                        </select>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>期望工作地点：</div>
                    <div class="inputtxt">
                        <input name="expectJobLocation" type="text" class="txt7"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>期望职位类别：</div>
                    <div class="inputtxt">
                        <input name="expectPosts" type="text" class="txt7"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <button id="next_btn" class="nextBtn">进一步完善</button>
                </div>
            </div>
        </div>
    </div>
    <div id="education_div" class="perRightcon" hidden>
        <div class="JlBoxTit">
            <p class="tit1">基本资料/求职意向</p>
            <div class="tit2"></div>
            <p class="tit3 on">最高学历</p>
        </div>
        <div class="JlBoxCon">
            <h1><span>最高学历</span>
                <div></div>
            </h1>
            <div class="JlBoxLeft">
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>学校名称：</div>
                    <div class="inputtxt">
                        <input name="schoolName" type="text" class="txt3"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>毕业时间：</div>
                    <div class="inputtxt">
                        <input id="graduation_time" name="graduationTime" type="date" class="txt8"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>学历：</div>
                    <div class="inputtxt">
                        <select class="txtcon txt2" id="degree">
                            <option value="初中及一下">初中及一下</option>
                            <option value="中专/中技">中专/中技</option>
                            <option value="高中">高中</option>
                            <option value="大专">大专</option>
                            <option value="硕士">硕士</option>
                            <option value="本科">本科</option>
                            <option value="博士">博士</option>
                        </select>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>学历类型：</div>
                    <div class="inputtxt">
                        <select class="txtcon txt2" id="degreeType">
                            <option value="普通高等教育（统招）">普通高等教育（统招）</option>
                            <option value="普通专升本（统招）">普通专升本（统招）</option>
                            <option value="成人高考">成人高考</option>
                            <option value="自考">自考</option>
                            <option value="电大">电大</option>
                            <option value="网络教育">网络教育</option>
                        </select>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>专业名称：</div>
                    <div class="inputtxt">
                        <input name="subjectName" type="text" class="txt3"/>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <div class="nametxt"><span>*</span>专业类别：</div>
                    <div class="inputtxt">
                        <select class="txtcon txt2" id="subjectType">
                            <option value="哲学">哲学</option>
                            <option value="经济学">经济学</option>
                            <option value="法学">法学</option>
                            <option value="教育学">教育学</option>
                            <option value="文学">文学</option>
                            <option value="历史学">历史学</option>
                            <option value="理学">理学</option>
                            <option value="工学">工学</option>
                            <option value="农学">农学</option>
                            <option value="医学">医学</option>
                            <option value="军事学">军事学</option>
                            <option value="管理学">管理学</option>
                            <option value="艺术学">艺术学</option>
                        </select>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="jldiv">
                    <button class="saveBtn">填写完毕</button>
                    <button id="previous_btn" class="preBtn">上一步</button>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="clear"></div>
<div class="footer">
</div>
</body>
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
<script>
    var userId;

    $(document).ready(function () {
        var constPhone = sessionStorage.getItem('phone');
        $.get("personalInformation/selectUser", {"phone": constPhone}, function (u) {
            userId=u.id;
        })
        $.get("personalInformation/selectInformation", {"phone": constPhone}, function (pi) {
            if (pi) {
                // 回显基本信息
                $("input[name='name']").val(pi.uname);

                // 设置性别
                if (pi.gender === "男") {
                    $(".inputtxt .sex").removeClass("on");
                    $(".inputtxt .sex").eq(0).addClass("on"); // 男
                } else {
                    $(".inputtxt .sex").removeClass("on");
                    $(".inputtxt .sex").eq(1).addClass("on"); // 女
                }

                $("input[name='brith']").val(pi.birth);
                $("input[name='nowLocation']").val(pi.nowLocation);
                $("input[name='householdLocation']").val(pi.householdLocation);
                $("input[name='hometown']").val(pi.hometown);
                $("input[name='phone']").val(pi.phone); // 设置手机号码
                $("input[name='email']").val(pi.email);

                // 设置求职状态
                $("#jobStatus").val(pi.jobStatus);

                // 设置相关工作经验（假设 pi.jobExperience 是“有”或“无”）
                if (pi.jobExperience === "有") {
                    $(".typeJob1").removeClass("on");
                    $(".typeJob1").eq(0).addClass("on"); // 有
                } else {
                    $(".typeJob1").removeClass("on");
                    $(".typeJob1").eq(1).addClass("on"); // 无
                }

                // 设置期望工作性质
                if (pi.expectJobValue === "全职") {
                    $(".typeJob2").removeClass("on");
                    $(".typeJob2").eq(0).addClass("on"); // 全职
                } else if (pi.expectJobValue === "兼职") {
                    $(".typeJob2").removeClass("on");
                    $(".typeJob2").eq(1).addClass("on"); // 兼职
                } else {
                    $(".typeJob2").removeClass("on");
                    $(".typeJob2").eq(2).addClass("on"); // 实习
                }

                $("#expectSal").val(pi.expectSal);
                $("input[name='expectJobLocation']").val(pi.expectJobLocation);
                $("input[name='expectPosts']").val(pi.expectPosts);

                // 回显教育信息
                $("input[name='schoolName']").val(pi.schoolName);
                $("input[name='graduationTime']").val(pi.graduationTime);
                $("#degree").val(pi.degree);
                $("#degreeType").val(pi.degreeType);
                $("input[name='subjectName']").val(pi.subjectName);
                $("#subjectType").val(pi.subjectType);


                $(".saveBtn").click(function () {
                    var information = getInformation();
                    $.get("personalInformation/update", {
                        "userId": userId,
                        "uname": information.uname,
                        "gender": information.gender,
                        "birth": information.birth,
                        "nowLocation": information.nowLocation,
                        "householdLocation": information.householdLocation,
                        "hometown": information.hometown,
                        "phone": information.phone,
                        "email": information.email,
                        "jobStatus": information.jobStatus,
                        "jobExperience": information.jobExperience,
                        "expectJobValue": information.expectJobValue,
                        "expectSal": information.expectSal,
                        "expectJobLocation": information.expectJobLocation,
                        "expectPosts": information.expectPosts,
                        "schoolName": information.schoolName,
                        "graduationTime": information.graduationTime,
                        "degree": information.degree,
                        "degreeType": information.degreeType,
                        "subjectName": information.subjectName,
                        "subjectType": information.subjectType
                    }, function (response) {
                        if (response) {
                            alert("修改成功")
                        } else {
                            alert("修改失败")
                        }
                    })
                })
            } else {
                $(".saveBtn").click(function () {
                    var information = getInformation();
                    $.get("personalInformation/insert", {
                        "userId": userId,
                        "uname": information.uname,
                        "gender": information.gender,
                        "birth": information.birth,
                        "nowLocation": information.nowLocation,
                        "householdLocation": information.householdLocation,
                        "hometown": information.hometown,
                        "phone": information.phone,
                        "email": information.email,
                        "jobStatus": information.jobStatus,
                        "jobExperience": information.jobExperience,
                        "expectJobValue": information.expectJobValue,
                        "expectSal": information.expectSal,
                        "expectJobLocation": information.expectJobLocation,
                        "expectPosts": information.expectPosts,
                        "schoolName": information.schoolName,
                        "graduationTime": information.graduationTime,
                        "degree": information.degree,
                        "degreeType": information.degreeType,
                        "subjectName": information.subjectName,
                        "subjectType": information.subjectType
                    }, function (response) {
                        if (response) {
                            alert("完善成功")
                        } else {
                            alert("完善失败")
                        }

                    })
                })
            }
        })
    });

    $(function () {
        $("#next_btn").on("click", function () {
            $("#base_div").hide();
            $("#education_div").show();
        });
        $("#previous_btn").on("click", function () {
            $("#base_div").show();
            $("#education_div").hide();
        });
    });

    var getInformation = function () {
        var information = {
            uname: $("[name='name']").val(),
            gender: $(".inputtxt .sex.on").text(), // 获取具有 'on' 类的性别文本
            birth: $("input[name='brith']").val(),
            nowLocation: $("input[name='nowLocation']").val(),
            householdLocation: $("input[name='householdLocation']").val(),
            hometown: $("input[name='hometown']").val(),
            phone: $("input[name='phone']").val(), // 获取手机号码文本
            email: $("input[name='email']").val(),
            jobStatus: $("#jobStatus").val(),
            jobExperience: $(".typeJob1.on").text(), // 获取具有 'on' 类的工作经验文本
            expectJobValue: $(".typeJob2.on").text(), // 获取具有 'on' 类的期望工作性质
            expectSal: $("#expectSal").val(),
            expectJobLocation: $("input[name='expectJobLocation']").val(),
            expectPosts: $("input[name='expectPosts']").val(),
            schoolName: $("[name='schoolName']").val(),
            graduationTime: $("input[name='graduationTime']").val(),
            degree: $("#degree").val(),
            degreeType: $("#degreeType").val(),
            subjectName: $("input[name='subjectName']").val(),
            subjectType: $("#subjectType").val()
        };
        return information
    };


</script>
</html>
